import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import ElementPlus from 'unplugin-element-plus/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import OptimizationPersist from "vite-plugin-optimize-persist";
import PkgConfig from "vite-plugin-package-config";

const config = require('./src/config/index');
// https://vitejs.dev/config/
export default defineConfig({
  optimizeDeps:{
    force:true,
    include:[
      'vue',
      'element-plus/es',
      'element-plus/es/components/button/style/index',
      'element-plus/es/components/select/style/index',
      'element-plus/es/components/option/style/index',
      'element-plus/es/components/message/style/index',
      'element-plus/es/components/row/style/index',
      'vue-router',
      'axios',
      'sass',
      'qs'
    ]
  },
	base:config.publicPath,
  server:{
    host:'localhost',
    https:false,
    cors:true,
    port:8080,
    strictPort:false,
  },
  css:{
    preprocessorOptions:{
      scss:{
        additionalData: `@use "@/assets/styles/element.scss" as *;`,
      }
    }
  },
  plugins: [
    vue(),
    PkgConfig(),
    OptimizationPersist(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [
        ElementPlusResolver({
          importStyle: 'sass',
        })
      ],
    }),
    ElementPlus({
      useSource: true,
    }),
  ],
  resolve:{
    alias:{
      '@':path.resolve(__dirname,'src')
    }
  },
	build:{
		outDir:'./dist',
		assetsDir:'static',
    minify:'terser',
    terserOptions:{
      compress:{
        drop_console:true,
        drop_debugger:true
      }
    }
	}
})

